/*
 * SunSpotApplication.java
 *
 * Created on Jul 28, 2011 8:26:14 PM;
 */

package org.sunspotworld;

import java.io.IOException;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import com.sun.spot.peripheral.radio.RadioFactory;
import com.sun.spot.resources.Resources;
import com.sun.spot.resources.transducers.ITriColorLEDArray;
import com.sun.spot.util.IEEEAddress;

/**
 * The startApp method of this class is called by the VM to start the
 * application.
 * 
 * The manifest specifies this class as MIDlet-1, which means it will be
 * selected for execution.
 */
public class SunSpotApplication extends MIDlet {

	private ITriColorLEDArray leds = (ITriColorLEDArray) Resources
			.lookup(ITriColorLEDArray.class);

	protected void startApp() throws MIDletStateChangeException {
		System.out.println("Hello, world: starting switching");

		long ourAddr = RadioFactory.getRadioPolicyManager().getIEEEAddress();

		System.out.println("Our radio address = "
				+ IEEEAddress.toDottedHex(ourAddr));

		try {
			Main.main(new String[] {});
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	protected void pauseApp() {
		// This is not currently called by the Squawk VM
	}

	/**
	 * Called if the MIDlet is terminated by the system. It is not called if
	 * MIDlet.notifyDestroyed() was called.
	 * 
	 * @param unconditional
	 *            If true the MIDlet must cleanup and release all resources.
	 */
	protected void destroyApp(boolean unconditional)
			throws MIDletStateChangeException {
	}
}
